package mlz.d_field;

import java.lang.reflect.Field;

/*
    通过反射机制获取 类中的所有成员变量
 */
public class FieldDemo {
    public static void main(String[] args) throws NoSuchFieldException {
        //1.获取类的字节码对象
        Class<Student> c = Student.class;

        //2.获取全部的field对象
        //Field[] fields = c.getFields();
        Field[] fields = c.getDeclaredFields();
        for(Field f : fields){
            System.out.println(f);
        }

        System.out.println("--------------------");

        //3.获取单个成员变量
        Field money = c.getDeclaredField("money");
        System.out.println(money);



    }
}
